package activiti.day03;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

/**
 * @Author: 蔡翔
 * @Date: 2019/9/4 13:44
 * @Version 1.0
 *
 * 启动流程实例时，添加进businessKey
 *
 *
 * 本质：act_ru_execution 表中的businessKey的字段存入业务标识
 */
public class BusinessKeyAdd {
    public static void main(String[] args) {
        // 1.得到ProcessEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        // 2.得到RunService对象
        RuntimeService runtimeService = processEngine.getRuntimeService();

        //3.启动流程实例，同时还要指定业务表示 businessKey，他本身就是请假单的id、调薪申请单(这里是1001)
        //第一个参数：是指流程定义的key
        //第二个参数：业务标识businessKey
        //在流程开始的时候，就给他指定businessKey，这个是我们可以认为设定的。
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("holiday","1001");

        //4.输出processInstance相关的属性 (以后我们也可以从这里那BusinessKey)
        System.out.println(processInstance.getBusinessKey());
    }
}
